﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ECONTACT.Bussiness;
using ECONTACT.DataLayer;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.Editors.DateTimeAdv;

namespace ECONTACT.Controller
{
    class MonHocCtrl
    {

        MonHocData m_MonHocData = new MonHocData();
        #region Hien thi ComboBox
        public void HienThiComboBox(ComboBoxEx comboBox)
        {
            comboBox.DataSource = m_MonHocData.LayDsMonHoc();
            comboBox.DisplayMember = "MaMH";
            comboBox.ValueMember = "MaMH";
        }
        public void HienThiComboBoxTen(ComboBoxEx comboBox)
        {
            comboBox.DataSource = m_MonHocData.LayDsMonHoc();
            comboBox.DisplayMember = "TenMH";
            comboBox.ValueMember = "MaMH";
        }
        #endregion

        #region Do du lieu vao DataGridView

        public void HienThi(DataGridViewX dGV,
                            TextBoxX txtMaMH,
                            TextBoxX txtTenMH,
                            TextBoxX txtHeSo)
        {
            BindingSource bS = new BindingSource();
            bS.DataSource = m_MonHocData.LayDsMonHoc();

            DataTable dT = m_MonHocData.LayDsMonHoc();

            txtMaMH.DataBindings.Clear();
            txtMaMH.DataBindings.Add("Text", bS, "MaMH");

            txtTenMH.DataBindings.Clear();
            txtTenMH.DataBindings.Add("Text", bS, "TenMH");

            txtHeSo.DataBindings.Clear();
            txtHeSo.DataBindings.Add("Text", bS, "Heso");

            //bN.BindingSource = bS;
            dGV.DataSource = bS;
        }
        #endregion

        public void LuuMonHoc(String TenMH, String HeSo)
        {
            m_MonHocData.LuuMonHoc(TenMH, HeSo);
        }

        public void UpdateMonHoc(String MaMH, String TenMH, String HeSo)
        {
            m_MonHocData.UpdateMonHoc(MaMH,TenMH, HeSo);
        }

        public void DeleteMonHoc(String MaMH)
        {
            m_MonHocData.DeleteMonHoc(MaMH);
        }
    }
}
